/**
  ******************************************************************************
  * File Name          : mini_car2.h
  * Description        : This file contains the common defines of the application
  ******************************************************************************
  */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MINI_CAR_2_H
#define __MINI_CAR_2_H
/* Includes ------------------------------------------------------------------*/

/* USER CODE BEGIN Includes */
#include "stm32f1xx_hal.h"
#include "bluetooth.h"
#include "rplidar.h"
#include "redcar_usb_command.h"

/* USER CODE END Includes */

/* Private define ------------------------------------------------------------*/

/* USER CODE BEGIN Private defines */
#define Min_Distance 500
//#define PI 3.14159
#define Max_Distance 1000
#define Min_Speed 0
#define Max_angle  PI/4
#define Min_angle  PI/4*(-1)
#define Min_Radius_Input 1
#define Max_Radius_Input 10

#define BASEBOUNDARY 200
#define BOUNDARY_RATIO 7
#define LIDAR_LOCATION_ORIGINAL 0
#define OBSTACLE_MAX_DIS 1000
typedef enum
{
    CAR_WHEEL_MOVE_FORWARD = 0,
    CAR_FW_LIFT_MOVE_UP,
    CAR_FW_LIFT_MOVE_DOWN,

    CAR_WHEEL_MOVE_BACKWARD,
    CAR_BW_LIFT_MOVE_UP,
    CAR_BW_LIFT_MOVE_DOWN,
 
    CAR_WHEEL_MOVE_RIGHT,
    CAR_WHEEL_MOVE_LEFT,
	  CAR_WHEEL_CW_TURN,
	  CAR_WHEEL_CCW_TURN,
	  CAR_SLIGHTLY_TURN_LEFT,
	  CAR_SHARPLY_TURN_LEFT,
	  CAR_SLIGHTLY_TURN_RIGHT,
	  CAR_SHARPLY_TURN_RIGHT,

    CAR_STOPPED,
	  CAR_SPEED_INIT
} MINI_CAR_State;
typedef enum
{
	CAR_FOLLOWER_MODE=0,
	CAR_BLUETOOTH_MODE
} MINI_CAR_Mode;

typedef  struct
{

	int8_t run_speed;
	float speed_pid_kp;
	float CW_Turn_kp;
	int8_t angle_speed;
	int8_t max_angle_speed,min_angle_speed;
	int8_t max_speed;
	int8_t wheel_1_speed,wheel_2_speed,wheel_3_speed,wheel_4_speed;
	float taget_coordinate_z,target_coordinate_x;
	float target_coord_atanNum;
	
	
}FOOD_CAR;

void Mini_Car_Run(FOOD_CAR *car);
void Food_Car_Init(FOOD_CAR *car,float kp,int8_t max_speed,float spin_kp,int8_t max_angleSpeed);
void CameraToSpeed(FOOD_CAR *car);
void Mini_Car_Stop(FOOD_CAR *car);
void Mini_Car_Forward_Setup(FOOD_CAR *car);
void Mini_Car_Backward_Setup(FOOD_CAR *car);
void Mini_Car_RightShift_Setup(FOOD_CAR *car);
void Mini_Car_LeftShift_Setup(FOOD_CAR *car);
void Mini_Car_CW_Turn(FOOD_CAR *car);
void Mini_Car_CCW_Turn(FOOD_CAR *car);
void xyz2speed2(FOOD_CAR *car);
float SpeedOutput(float input, float minInput, float minSpeed, float maxInput, float maxSpeed);
void Food_Car_EmergencyStop(FOOD_CAR *food_car);
void Food_Car_BluetoothControl(FOOD_CAR *food_car,T_Command cmd);
uint8_t Get_CarState_Lidar(Lidar_Type* lidar1,int8_t run_speed,int right_length,int left_length);
void Car_Joystick_Mode_Init(FOOD_CAR *car,float kp,int8_t max_speed);
 void Car_Joystick_Control_Mode(FOOD_CAR *car,Joystick_Command cmd);


/* USER CODE END Private defines */

#endif /* __MINI_CAR_2_H */

